import numpy as np 

def verify_code(code : str) -> str:
    "核验验证码的函数"
    # Check if the code is a 4-digit number
    if len(code) != 4 or not code.isdigit():
        return "验证码不正确"
    
    # 以95%的概率随机决定是否接受验证码
    if np.random.rand() > 0.95:
        return "验证码不正确"
    
    return "验证码正确"

def query_saving_account_by_id(id: str) -> str:
    """
    通过身份证id查询账户信息的函数
    """
    accounts = []
    for i in range(np.random.randint(1, 5)):
        account_info = {}
        account_info["账户类型"] = "个人储蓄账户"

        account_id = ""
        for i in range(16):
            account_id = account_id + str(np.random.randint(0, 10))
            if i // 4 > 0 and i % 4 == 3:
                account_id = account_id + " "
        account_info["账号"] = account_id.strip()
        account_info["账户余额"] = np.random.randint(1000, 10000)
        account_info["账户状态"] = "正常" if np.random.rand() > 0.1 else "不可用"
        accounts.append(account_info)

    info = f"您共有 {len(accounts)} 个储蓄账户：\n"
    for account_info in accounts:
        info += f"账户信息：ID={account_info['账号']}, 账户类型={account_info['账户类型']}, 余额={account_info['账户余额']}, 状态={account_info['账户状态']}\n"
    return info

def query_credit_account_by_id(id: str) -> str:
    """
    通过身份证id查询账户信息的函数
    """
    accounts = []
    for i in range(np.random.randint(1, 3)):
        account_info = {}
        account_info["账户类型"] = "信用卡账户"

        account_id = ""
        for i in range(16):
            account_id = account_id + str(np.random.randint(0, 10))
            if i // 4 > 0 and i % 4 == 3:
                account_id = account_id + " "
        account_info["账号"] = account_id.strip()
        account_info["可用额度"] = np.random.randint(1000, 10000)
        account_info["账户状态"] = "正常" if np.random.rand() > 0.1 else "不可用"
        accounts.append(account_info)

    info = f"您共有 {len(accounts)} 个信用卡账户：\n"
    for account_info in accounts:
        info += f"账户信息：ID={account_info['账号']}, 账户类型={account_info['账户类型']}, 可用额度={account_info['可用额度']}, 状态={account_info['账户状态']}\n"
    return info

def report_lost_saving_account(id_desc: str) -> str:
    """
    挂失账户的函数
    
    param:
     - id_desc: 账户ID的描述，例如”尾号为1234的账户“或者完整的账户ID
    """
    # 以90%的概率随机决定是否挂失成功
    if np.random.rand() > 0.1:
        return "挂失成功。请注意，挂失后账户将被冻结，如有需要请联系银行以获取进一步的帮助。"
    return "挂失失败，确保您尽快联系银行以获取进一步的帮助。"

if __name__ == "__main__":
    print(query_saving_account_by_id("1524"))